import { ref, computed } from "vue";
import { defineStore } from "pinia";
import { time } from "../components/Method";
import { Login } from "../api/index";

export const useCounterStore = defineStore("counter", () => {

  const useHomeStore = defineStore("counter",{
    // 开启数据持久化
    persist: true
    // ...省略
  });


  // 我的收藏数据
  const mycollect=ref([])


  // 登录时获取到的用户信息
  const loginArr=ref([])
  

  // 随机数
  function getNum(a, b) {
    let max = Math.max(a, b);
    let min = Math.min(a, b);

    return parseInt(Math.random() * (max - min + 1) + min);
  }


  // 正计时
  function times(val) {
    const day = ref(time(val));
    setInterval(() => {
      day.value = time(val);
    }, 1000);
    return day;
  }

  return { getNum, times ,loginArr,mycollect};
});
